
//172.21.0.1本地ip地址
//120.53.2.97服务器地址
const express = require('express');
const app = express()
const history = require('connect-history-api-fallback');
const compression = require('compression');
app.use(express.urlencoded());
app.use(express.json());
app.use(compression())
app.use(history());
app.use(express.static(__dirname + '/public'))


function getRoles(){
    // return ['admin']
    return ['viewer']
}

app.post('/login',(req,res)=>{
    let {username,password} = req.body;
    res.send(
        {
            code:1,
            msg:'登录成功',
            data:{
                token:'TOKEN',
                username
            }
        }
    )
})

app.get('/roles',(req,res)=>{
    let roles = getRoles();
    res.send(
        {
            code:1,
            msg:'succeed',
            roles
        }
    )
})

app.listen(9090)